package com.example.demo.service.impl;

import com.example.demo.entity.Resume;
import com.example.demo.mapper.ResumeMapper;
import com.example.demo.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Service
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeMapper resumeMapper;

    @Override
    public boolean save(Resume resume) {
        resume.setCreateTime(LocalDateTime.now());
        resume.setUpdateTime(LocalDateTime.now());
        return resumeMapper.insert(resume) > 0;
    }

    @Override
    public boolean update(Resume resume) {
        resume.setUpdateTime(LocalDateTime.now());
        return resumeMapper.update(resume) > 0;
    }

    @Override
    public Resume findById(Long id) {
        return resumeMapper.findById(id);
    }

    @Override
    public List<Resume> findByUserId(Long userId) {
        return resumeMapper.findByUserId(userId);
    }

    @Override
    public boolean delete(Long id) {
        return resumeMapper.delete(id) > 0;
    }
}